const { orderFormatterError } = require("../constants/err.type");

const validator = (rules) => {
  return async (ctx, next) => {
    try {
      ctx.verifyParams(rules);
    } catch (error) {
      console.error(error);
      return (ctx.body = orderFormatterError);
    }
    await next();
  };
};

module.exports = {
  validator,
};
